<!DOCTYPE HTML>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
		<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
		<title>工单详情信息</title>
		<link rel="stylesheet" type="text/css" href="../css/mui.min.css" />
		<link rel="stylesheet" type="text/css" href="../css/common.css" />
		<style type="text/css">
			.mui-table-view-chevron .mui-table-view-cell {
				padding-right: 20px!important;
			}
			h5 {
				color: #0062CC;
			}

		</style>
	</head>

	<body>
		<div class="mui-content content-padded_bottom" id="ordrDetailContent">
			<script type="text/template" id="items">
				<ul class="mui-table-view mui-table-view-chevron">
					<li class="mui-table-view-cell">
						<div class="mui-table">
							<div class="mui-table-cell mui-col-xs-4">
								<h5 class="mui-ellipsis">编号：</h5>
							</div>
							<div class="mui-table-cell mui-col-xs-8 mui-text-right">
								<span class="mui-h5">{{datas.wonum}}</span>
							</div>
						</div>
					</li>
					<li class="mui-table-view-cell">
						<div class="mui-table">
							<div class="mui-table-cell mui-col-xs-4">
								<h5 class="mui-ellipsis">类型：</h5>
							</div>
							<div class="mui-table-cell mui-col-xs-8 mui-text-right">
								<span class="mui-h5">{{datas.worktype}}</span>
							</div>
						</div>
					</li>
					<li class="mui-table-view-cell">
						<div class="mui-table">
							<div class="mui-table-cell mui-col-xs-4">
								<h5 class="mui-ellipsis">状态：</h5>
							</div>
							<div class="mui-table-cell mui-col-xs-8 mui-text-right">
								<span class="mui-h5">{{datas.status}}</span>
							</div>
						</div>
					</li>
					<li class="mui-table-view-cell">
						<div class="mui-table">
							<div class="mui-table-cell mui-col-xs-4">
								<h5 class="mui-ellipsis">标题：</h5>
							</div>
							<div class="mui-table-cell mui-col-xs-8 mui-text-right">
								<span class="mui-h5">{{datas.taskDesc}}</span>
							</div>
						</div>
					</li>
				</ul>
				<ul class="mui-table-view mui-table-view-chevron type_list_spair">
					<li class="mui-table-view-cell">
						<div class="mui-table">
							<div class="mui-table-cell mui-col-xs-4">
								<h5 class="mui-ellipsis">位置：</h5>
							</div>
							<div class="mui-table-cell mui-col-xs-8 mui-text-right">
								<span class="mui-h5">{{datas.location}}</span>
							</div>
						</div>
					</li>
					<li class="mui-table-view-cell">
						<div class="mui-table">
							<div class="mui-table-cell mui-col-xs-4">
								<h5 class="mui-ellipsis">位置描述：</h5>
							</div>
							<div class="mui-table-cell mui-col-xs-8 mui-text-right">
								<span class="mui-h5">{{datas.locationDesc}}</span>
							</div>
						</div>
					</li>
				</ul>
				<ul class="mui-table-view mui-table-view-chevron type_list_spair">
					<li class="mui-table-view-cell">
						<div class="mui-table">
							<div class="mui-table-cell mui-col-xs-4">
								<h5 class="mui-ellipsis">维修区域：</h5>
							</div>
							<div class="mui-table-cell mui-col-xs-8 mui-text-right">
								<span class="mui-h5">{{datas.cRegion}}</span>
							</div>
						</div>
					</li>
				</ul>
				<ul class="mui-table-view mui-table-view-chevron type_list_spair">
					<li class="mui-table-view-cell">
						<div class="mui-table">
							<div class="mui-table-cell mui-col-xs-4">
								<h5 class="mui-ellipsis">资产：</h5>
							</div>
							<div class="mui-table-cell mui-col-xs-8 mui-text-right">
								<span class="mui-h5">{{datas.assetnum}}</span>
							</div>
						</div>
					</li>
					<li class="mui-table-view-cell">
						<div class="mui-table">
							<div class="mui-table-cell mui-col-xs-4">
								<h5 class="mui-ellipsis">资产名称：</h5>
							</div>
							<div class="mui-table-cell mui-col-xs-8 mui-text-right">
								<span class="mui-h5">{{datas.assetDesc}}</span>
							</div>
						</div>
					</li>
				</ul>
				<ul class="mui-table-view mui-table-view-chevron type_list_spair">
					<li class="mui-table-view-cell">
						<div class="mui-table">
							<div class="mui-table-cell mui-col-xs-4">
								<h5 class="mui-ellipsis">负责人</h5>
							</div>
							<div class="mui-table-cell mui-col-xs-8 mui-text-right">
								<span class="mui-h5">{{datas.lead}}</span>
							</div>
						</div>
					</li>
					<li class="mui-table-view-cell">
						<div class="mui-table">
							<div class="mui-table-cell mui-col-xs-4">
								<h5 class="mui-ellipsis">姓名：</h5>
							</div>
							<div class="mui-table-cell mui-col-xs-8 mui-text-right">
								<span class="mui-h5">{{datas.leadName}}</span>
							</div>
						</div>
					</li>
				</ul>
				<ul class="mui-table-view mui-table-view-chevron type_list_spair">
					<li class="mui-table-view-cell">
						<div class="mui-table">
							<div class="mui-table-cell mui-col-xs-4">
								<h5 class="mui-ellipsis">主管人：</h5>
							</div>
							<div class="mui-table-cell mui-col-xs-8 mui-text-right">
								<span class="mui-h5">{{datas.supervisor}}</span>
							</div>
						</div>
					</li>
					<li class="mui-table-view-cell">
						<div class="mui-table">
							<div class="mui-table-cell mui-col-xs-4">
								<h5 class="mui-ellipsis">姓名：</h5>
							</div>
							<div class="mui-table-cell mui-col-xs-8 mui-text-right">
								<span class="mui-h5">{{datas.supervisorName}}</span>
							</div>
						</div>
					</li>
				</ul>
			
				<ul class="mui-table-view mui-table-view-chevron type_list_spair">
					<li class="mui-table-view-cell">
						<div class="mui-table">
							<div class="mui-table-cell mui-col-xs-4">
								<h5 class="mui-ellipsis">计划开始时间：</h5>
							</div>
							<div class="mui-table-cell mui-col-xs-8 mui-text-right">
								<span class="mui-h5">{{datas.schedstart}}</span>
							</div>
						</div>
					</li>
					<li class="mui-table-view-cell">
						<div class="mui-table">
							<div class="mui-table-cell mui-col-xs-4">
								<h5 class="mui-ellipsis">计划结束时间：</h5>
							</div>
							<div class="mui-table-cell mui-col-xs-8 mui-text-right">
								<span class="mui-h5">{{datas.schedfinish}}</span>
							</div>
						</div>
					</li>
				</ul>
				<ul class="mui-table-view mui-table-view-chevron type_list_spair">
					<li class="mui-table-view-cell">
						<div class="mui-table">
							<div class="mui-table-cell mui-col-xs-4">
								<h5 class="mui-ellipsis">实际开始时间：</h5>
							</div>
							<div class="mui-table-cell mui-col-xs-8 mui-text-right">
								<span class="mui-h5">{{datas.actstart}}</span>
							</div>
						</div>
					</li>
					<li class="mui-table-view-cell">
						<div class="mui-table">
							<div class="mui-table-cell mui-col-xs-4">
								<h5 class="mui-ellipsis">实际结束时间：</h5>
							</div>
							<div class="mui-table-cell mui-col-xs-8 mui-text-right">
								<span class="mui-h5">{{datas.actfinish}}</span>
							</div>
						</div>
					</li>
				</ul>
				<ul class="mui-table-view mui-table-view-chevron type_list_spair">
					<li class="mui-table-view-cell detail">
						<div class="mui-table">
							<div class="mui-table-cell mui-col-xs-4">
								<h5 class="mui-ellipsis">图片附件：</h5>
							</div>
						</div>
						<div class="mui-table">
							<ul class="mui-table-view mui-table-view-chevron type_list_spair" id="imgList">
								<!-- 模板引擎 -->
							</ul>
						</div>
					</li>
				</ul>
				<ul class="mui-table-view mui-table-view-chevron type_list_spair">
					<li class="mui-table-view-cell detail">
						<div class="mui-table">
							<div class="mui-table-cell mui-col-xs-4">
								<h5 class="mui-ellipsis">附件：</h5>
							</div>
						</div>
						<div class="mui-table">
							<ul class="mui-table-view mui-table-view-chevron type_list_spair" id="accessories">
								<!-- 模板引擎 -->
							</ul>
						</div>
					</li>
				</ul>
				{{if datas.status!=='关闭' && datas.status!=='完成'}}
				<div class="fixed_btn" onclick="editOrder()">
					<i class="edit-icon"></i>修改工单
				</div>
				{{/if}}
			</script>
		</div>
	</body>
	<script type="text/javascript" src="../script/api.js"></script>
	<script src="../script/mui.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../script/common.js" type="text/javascript" charset="utf-8"></script>
	<script src="../script/template.js"></script>
	<script type="text/temmlate" id="tmpList">
		{{each datas as item}}
		<li class="mui-table-view-cell" tapmode onclick="showRemotePicture(baseURL + 'downloadFile?docinfoid='+'{{item.docinfoid}}', '{{item.description}}')">
			<img class="mui-media-object" src="{{item.src}}" />
		</li>
		{{/each}}
	</script>
	<script type="text/temmlate" id="tmpList2">
		{{each datas as item}}
			<li class="mui-table-view-cell" onclick='uploadXlsx("{{item.docinfoid}}", "{{item.description}}")'>
				<span class="mui-h5">{{item.description}}</span>
			</li>
		{{/each}}
	</script>
	<script type="text/javascript">
		var wonum,
			worktype,
			status,
			desc,
			locations,
			locationDesc,
			cRegion,
			assetnum,
			assetDesc,
			lead,
			leadName,
			schedstart,
			schedfinish,
			workstatus;
		var arr = [];
//		var buttonGroups =['工单计划任务', '工单人工计划', '工单物料计划', '工单服务计划', '工单工器具计划', '工单实际任务', '工单实际人工', '工单实际物料', '工单实际服务', '工单实际工器具', '变更状态', '报告停工时间', '转到测点','巡点检项'];
		var buttonGroups =['工单计划任务', '工单人工计划', '工单物料计划', '工单工器具计划', '工单实际任务', '工单实际人工', '工单实际物料', '工单实际工器具', '变更状态', '报告停工时间', '转到测点','巡点检项'];
		apiready = function() {
			onLoadData();
			Refresh(function() {
				tjsearch();
			});
		api.addEventListener({
            name: 'onload'
        }, function(ret, err) {
        	if (ret.value.isrefersh == 'yes') {
        		onLoadData();
        	}
        });
        api.addEventListener({
			name: 'keyback'
		}, function(ret, err) {
			console.log('keyback');
			$api.rmStorage('workstatus');
			setTimeout(function(){
				api.closeWin();
			},100)
		});
		api.addEventListener({
			name: 'navbackbtn'
		}, function(ret, err) {
			console.log('navbackbtn');
			$api.rmStorage('workstatus');
			setTimeout(function(){
				api.closeWin();
			},100)
		});
			api.addEventListener({
				name: 'navitembtn'
			}, function(ret, err) {
				if(ret.type == 'right') {
//					if (workstatus != '关闭' && workstatus != '完成'){
					api.actionSheet({
						title: '请选择一项操作',
						cancelTitle: '取消',
						buttons: buttonGroups
					}, function(ret, err) {
						var index = ret.buttonIndex;
						switch(index) {
							case 1:
								openNewWin('work_order_manage_tast', '工单计划任务', {
									wonum: api.pageParam.wonum,
									workorderid: api.pageParam.workorderid,
									isPlan: 1,
									workstatus: workstatus
								});
								break;
							case 2:
								openNewWin('work_order_manage_personPlan', '工单人工计划', {
									linetype: 4,
									wonum: api.pageParam.wonum,
									workstatus: workstatus
								});
								break;
							case 3:
								openNewWin('work_order_manage_sthPlan', '工单物料计划', {
									linetype: 1,
									wonum: api.pageParam.wonum,
									workstatus: workstatus
								});
								break;
//							case 4:
//								openNewWin('work_order_manage_servicePlan', '工单服务计划', {
//									linetype: 2,
//									wonum: api.pageParam.wonum
//								});
//								break;
							case 4:
								openNewWin('work_order_manage_toolPlan', '工单工器具计划', {
									linetype: 3,
									wonum: api.pageParam.wonum,
									workstatus: workstatus
								});
								break;
							case 5:
								openNewWin('work_order_manage_tast', '工单实际任务', {
									wonum: api.pageParam.wonum,
									workorderid: api.pageParam.workorderid,
									isPlan: 0,
									workstatus: workstatus
								});
								break;
							case 6:
								openNewWin('work_order_manage_personActual', '工单实际人工', {
									linetype: 8,
									wonum: api.pageParam.wonum,
									workstatus: workstatus
								});
								break;
							case 7:
								openTastWin('work_order_manage_sthActual', '工单实际物料', {
									linetype: 5,
									wonum: api.pageParam.wonum,
									workstatus: workstatus
								});
								break;
//							case 9:
//								openNewWin('work_order_manage_serviceActual', '工单实际服务', {
//									linetype: 6,
//									wonum: api.pageParam.wonum
//								});
//								break;
							case 8:
								openNewWin('work_order_manage_toolActual', '工单实际工器具', {
									linetype: 7,
									wonum: api.pageParam.wonum,
									workstatus: workstatus
								});
								break;
							case 9:
								openSaveWin('work_order_manage_changeStatus', '变更状态', {
									wonum: api.pageParam.wonum,
									workorderid: api.pageParam.workorderid,
									wonum: wonum,
									worktype: worktype,
									status: status,
									desc: desc,
									managerNum: lead,
									managerName: leadName,
									workstatus: workstatus
								});
								break;
							case 10:
								openSaveWin('work_stop_time', '报告停工时间', {
									wonum: api.pageParam.wonum,
									workstatus: workstatus
								});
								break;
							case 11:
								openTastWin('status_monitoing', '测点列表',{
				                	cRegion: locations,
									assetnum: assetnum,
									workstatus: workstatus
				                });
               				break;
               				case 12:
								openWin('tmp_order', '巡点检项', {
				                    background: '#6098de',
				                    color: '#fff',
				                    rightButtons: [{
				                        iconPath: "widget://image/save-icon.png"
				                    }]
				                }, {
				                	workorderid: api.pageParam.workorderid,
									workstatus: workstatus
				                });
               				break;
						}
					});
//					} else {
//						Toast('工单已关闭，不可操作！');
//					}
				}
			});
		}

		function onLoadData() {
			ajaxrd("queryOrderDetail", {
				workorderid: api.pageParam.workorderid,
				wonum: api.pageParam.wonum,
				isTode: api.pageParam.isTode ? api.pageParam.isTode : 0
			}, function(ret, err) {
				api.refreshHeaderLoadDone();
				workstatus = ret.status;
				$api.setStorage('workstatus', ret.status);
				AddData('items', 'ordrDetailContent', ret, false);
				AddData('tmpList2', 'accessories', ret.attachList);
				wonum = ret.wonum;
				worktype = ret.worktype;
				status = ret.status;
				desc = ret.taskDesc;
				locations = ret.location;
				locationDesc = ret.locationDesc;
				cRegion = ret.cRegion;
				assetnum = ret.assetnum;
				assetDesc = ret.assetDesc;
				lead = ret.lead;
				leadName = ret.leadName;
				schedstart = ret.schedstart;
				schedfinish = ret.schedfinish;
				actstart = ret.actstart;
				actfinish = ret.actfinish;
				var arr = []
				ret.imgList.forEach(function(item,index){
					arr.push({
						docinfoid: item.docinfoid,
						description: item.description,
						src: baseURL + 'downloadFile?docinfoid=' + item.docinfoid_sl
					})
				})
//				for(var item of ret.imgList) {
//					arr.push({
//						docinfoid: item.docinfoid,
//						description: item.description,
//						src: baseURL + 'downloadFile?docinfoid=' + item.docinfoid_sl
//					})
//				}
				var html = template('tmpList', {
					datas: arr
				});
				$api.html($api.byId('imgList'), html);
			})
			ajaxrd("queryUserGroup", {}, function(ret, err) {
				var datas = ret.data;
				for(var i = 0; i < datas; i++) {
					switch(datas[i].description) {
						case '':
						break;
					}
				}
			})
		}

		function editOrder() {
			openSaveWin('work_order_manage_edit', '修改工单', {
				workorderid: api.pageParam.workorderid,
				wonum: api.pageParam.wonum,
				// docinfoid_sl:api.docinfoid_sl,
				// baseURL:baseURL
			})
		}
		String.prototype.endWith=function(endStr){
	      var d=this.length-endStr.length;
	      return (d>=0&&this.lastIndexOf(endStr)==d);
	  }
		function uploadXlsx(id,name){
			var str = name.toLocaleLowerCase()
			var index = str.lastIndexOf("\.");
			var newString = str.substring(index +1, str.length);
			if(str.endWith("doc") || str.endWith("docx") || str.endWith("xls") || str.endWith("xlsx") || str.endWith("ppt") || str.endWith("pptx")){
				showExcelFile(baseURL + 'downloadFile?docinfoid=' + id, guid()+'.'+ newString)
			}else{
				showRemotePicture(baseURL + 'downloadFile?docinfoid=' + id+'', guid()+'.'+ newString)
			}
		}
	</script>

</html>
